package cn.gson.crm.control.follow;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.gson.crm.control.base.BaseServlet;
import cn.gson.crm.model.dao.FollowDao;
import cn.gson.crm.model.po.FollowPo;
@WebServlet("/follow/update")
public class FollowUpdateServlet extends BaseServlet{
	private FollowDao followDao = new FollowDao();
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	@Override
	protected void get(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String stuid = request.getParameter("stuid");
		String staffid = request.getParameter("staffid");
		request.getSession().setAttribute("stuid", stuid);
		request.getSession().setAttribute("staffid", staffid);
		String followid = request.getParameter("followid");
		FollowPo followPo = new FollowPo();
		followPo = followDao.getOneFollowPoList(followid);
		request.setAttribute("followPo", followPo);
		forward("follow/follow_update.jsp");
	}
	@Override
	protected void post(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String followid = request.getParameter("id");
		String followStyle = request.getParameter("followStyle");
		String followAgainTime = request.getParameter("followAgainTime");
		String followContent = request.getParameter("followContent");
		String stuid = (String) request.getSession().getAttribute("stuid");
		followDao.updateFollowPoList(stuid,followid, followStyle, followAgainTime, followContent);
		String staffid = (String) request.getSession().getAttribute("staffid");
		request.removeAttribute("stuid");
		request.removeAttribute("staffid");
		request.setAttribute("stuid", stuid);
		request.setAttribute("staffid", staffid);
		forward("../../allot/one");
	}

}
